const query = require('./query')

const insertOrder = async (order) => {
  const sql = 'insert into `order`(order_num,goodsInfo_id,goods_count,user_id,create_time,address_id) values ?'
  try {
    const result = await query(sql, [order])
    return result
  } catch (error) {
    return Promise.reject(error)
  }
}

const updateOrderState = async (orderNum, order_state) => {
  const sql = 'update `order` set order_state = ? where order_num = ?'
  try {
    const result = await query(sql, [order_state, orderNum])
    return result
  } catch (error) {
    return Promise.reject(error)
  }
}
module.exports = {
  insertOrder,
  updateOrderState
}